package com.simple.protal.web.api.controller;


import com.simple.protal.web.service.WebAppService;
import com.xxl.sso.core.conf.Conf;
import com.xxl.sso.core.user.XxlUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

@RestController
public class IndexController {

    @Autowired
    private WebAppService webAppService;

    @GetMapping("/getApp")
    public Object getApp(){
        return webAppService.getApp();
    }

    @RequestMapping("/")
    public String index(Model model, HttpServletRequest request) {

        XxlUser xxlUser = (XxlUser) request.getAttribute(Conf.SSO_USER);
        model.addAttribute("xxlUser", xxlUser);
        return "success";
    }

}
